﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using DLM.Infrastructure.Domain;


namespace DLM.Domain.Model
{
    public class Notice : IValidatableObject, IAggregateRoot
    {
        public int NoticeID { get; set; }

        [Required(ErrorMessage = "标题不允许为空")]
        [StringLength(20,ErrorMessage="最大长度为20")]
        public string Subject { get; set; }

        public string Content { get; set; }

        public System.DateTime CreateDate { get; set; }

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (string.IsNullOrEmpty(Subject))
            {
                yield return new ValidationResult("标题不允许为空", new string[] { "Subject" });
            }
        }
    }
}
